<template>
  <el-button type="danger" size="small" @click="open()">删除</el-button>
</template>

<script>
import qs from "qs";

export default {
  inject: ['reload'],
  name: "BlogDelete",
  props: ['bid'],
  methods: {
    open() {
      this.$confirm('是否确认删除博客?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.deleteBlog();
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        });
      });
    },
    deleteBlog() {
      this.axios.post('/blog/deleteBlog', qs.stringify({
        bid: this.bid,
      })).then((response) => {
        console.log(response);
        this.$message.success(response.data.tip.toString());
        this.reload();
      });
    }
  }
}
</script>

<style scoped>

</style>
